﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace SiteManager.Core.Helper
{
    public class ConfigHelper
    {
        private static string CacheTime_Name = "CacheTime";
        private static string PageRow_Name = "PageRow";
        private static ConfigHelper config = new ConfigHelper();

        private ConfigHelper() { }
        
        public static ConfigHelper Get { get { return config; } }

        public object this[string key]
        {
            get
            {
                return ConfigurationManager.AppSettings[key];
            }
        }

        public static int CacheTime
        {
            get 
            {
                //if (CacheHelper.Get[CacheTime_Name] == null)
                //{
                //    CacheHelper.Insert(CacheTime_Name, ConfigurationManager.AppSettings[CacheTime_Name]);
                //}
                //return (int)CacheHelper.Get[CacheTime_Name];
                return Convert.ToInt32(Get[CacheTime_Name]);
            }
        }

        public static int PageRow
        {
            get
            {
                //if (CacheHelper.Get[PageRow_Name] == null)
                //{
                //    CacheHelper.Insert(CacheTime_Name, ConfigurationManager.AppSettings[PageRow_Name]);
                //}
                //return (int)CacheHelper.Get[PageRow_Name];
                return Convert.ToInt32(Get[PageRow_Name]);
            }
        }
    }
}